sorted clear flags issue