Fixed js issue while creating a new state