finish scan and parse function