Ignore this comment. I didn't look far enough. (A renaming of the tmp variable could be helpful)