Optimized function isInter()