fixing scanning and adding some console logging to debug