Implemented state generator in new way