refactoring to work with es_command