Added exception handling around scan