Added border checking to rectangle