debug: factor out helpers