added collision detection for the walls