bug fix for sorting activities