optimize kss state generator