Refactoring: more easy to understand processing flow