fix recursion in scanner