fixes issue #497

Applied fix and tested locally