fix error checking, sort-of