liberal use of defer to close connections