scanner: better use of assert