implemented collect and deadlock check