Fix note selection algorithm