document intended spec mismatch
move closures into a new function (cleaner code)
move closures into a new function (cleaner code)