A prettier fix for #36

A prettier fix for #36
My last patch is a quick patch aiming to fix the problem ASAP. This patch behaves exactly the same as the last one but is much more prettier and cleaner.
Maybe you can merge this and stack it until the next release.