refactoring and additional before and after processing functionality for multiple before and after processes