Added border collision detection