rewrite a few lines to non-nesting