Fix early termination bug from previous commit
Add the atom function