exportind searched data as excel file and did some refactoring