implementation of #843