refactor twice search