handling case where right or bottom == x or y