remove another letfn
more refactoring and formatting