Add a null check to Task class as well