solution to search for range function