fixed some bugs in the adding process