repair color gen function