fixes issue #8 as suggested by szincsakandras