Eliminated unnecessary variables in isBetween