Need help with the scan function