One last thing: can you get rid of the if range at the end? It's already inside a check for range being defined