Checking grid bounds