Fix bug in PR #1187

After merging PR #1187 I discovered that it contained a bug in the order
in which items were resolved. I have made this follow up commit to fix
that.