start splitting scan.php into seperate stages