search.substr is not a function