Added collision detection and exit on collision