Refactoring impl of the main processing pipeline