try to fix #844

Not sure whether I did the right. Entirely not familiar with the old code base now :(