a working version with reducing number of tasks