Improved search logic and added preliminary csv export