added logic for overlap and comparison of coordinates