rectified code, copy-paste messed up the code, that's why the reduce phase went wrong