bug fix in scanning