Refactoring the procedure functionality