Implemented scanning logic