fixes issue #16 and #12