minor refactoring of nested lets