Fixing reduce function to the pull request