initial workable impl
initial workable impl
detect dead lock
simplified