Update util.py

Proposal for a fix for issue #40