Fixed bug in creating state