added try catch for range