Added the collision detection functionality to the program