added new variables for mega sorting