fix typo and infinite loop in selectedNote()