cleaning code; refactored debug()
cleaning up