refactor the checkintersection function