fix sql query and sorting in followup track function