implementation of #191