factor out debug stuff so its easily toggleable