BUGFIX: use functools.reduce for python3 compatibility