Cleaner way to implement fix for issue #85 courtesy of parndt