Refactor activity query for project