logic in sorting tasks corrected