Possible fix for #57
Thanks to powerlord's code :)