add job scheduler & refactor code