fixed bug in the add method