Minor fix for error checking