Moved updating of indexRange to function
Inlined variable
Refactoring