refactored some parts of the lexer