Fixed some syntax/logic errors in add()