refactor codes and add error message when no note to display