better scanning code