fixed bug in add_atom and remove_atom functions