Refactored add() method