refactored lexer