fixed scanner logic