refactor opening notes and writing files