broke up scan function.