refactor and add entry point