refactored search engine, used list to make it more deterministic