tweaked takeScan function