fixes issue #66 with some limitations