closes remainder issue #45 and fixes issue #40