surrounded debugging prints with `if debug`; could be cleaner, but not bad