refactor to make sure it catches failure