Add level_fun in state type