move error handling to run