Fixed bugs

Fixed an import and detecting an error.