Updated add() method to accept array or string as input