added collision detection, debugging still enabled