move error reporting to the top