perfomance fix
length state