optimize scaner codes