move debug output to where it properly belongs