Added simple edge collision detection