better implementation of fix for #68 re-reported by @llybin