Fix bug with ranges