Refactor notes controller