fix issue #977

fix issue #977
Fixed by f13eab644ad5f9616d3233e0354bb6ff3e98c91b