Extract check_status() and use it wherever is needed.