this will be rebased after PR #828 is merged