fix scratch growing bugs
modify scratch detect routine