added import of reduce from functools to support python3