modified logics of range() function.