correct an error in the code. Previous version will print the wrong
atom index.