refactor folder scan and push2es functionalities