implemented basic collision detection