Fixes error case where state is undefined