Wrote a simple 'scan' function