Added trap for error that causes segmentation fault