Refactoring the add action