scanning function