working on scanPage function but now everything is broken :(