Fixed bugs in add