Fix getitem error in tasks.py