Fixed bug in scanner