Small tweaks to logic at endpoints

Changed >= and > a bit to include/exclude end points better