Fix critical bug to block forever in scanning module