refactored code for search logging and retrieving search logs