added check for out of border