fix mapping out of boundary