corrected out of bound coordinates