collision detection working. code needs refactoring