added bottom and right checking