add explicit null check for moving tasks from pending to running