edge detection fixed for collisions