Fix logic error in TaskGenerator