Search JS refactor