Moved comparison part from mapper to reducer