Using tasks instead of loops