collision detection working for left and right barriers