refactored esgsearch