modified state generator by Dmitry Demidov added