Refactored lexer with case..when instead of all the if's