The implementation of add() function.