refactored process flow