fix checking for overlap