first draft at better parser/scanner