refactor add to_atom method