code cleanups from comments - eliminate nesting and exit cleaner