add some code from renette
resolve merge conflict