add checking for error states