Implemented simple collision detection