Refactor the add action