factor out quit
fix syntax
better url error handling
prevent bofh duplication