collision detection function added