coordinate overflow check added