Fix segmentation fault error. Needed to initialize state pointer