factor out quit