refactor js search