scanner and functions for ex 3.2