fix some api issues
fix the way ranges are checked