different implementation of #29