Fixed search field bug + refactoring