refactor lex