refactoring lexer