added scan2 function