dapetcu21 's patch from issue #163