fixed #144.  needs testing