fixed error with collision detection