version 2 of final notes, much more general