factor out quit
fix syntax
better url error handling