fixed reduce bug which #13 pointed out