added check for error