LexerEngine class scan method update.

Code passes test cases TC1, TC2