Fixed logic error in determining whether tasks have been completed.