improved scan method

added loop to wait for result