implemented new collision detection