Updated  GetLastTask method in Tasks