refactor of Scanner class