refactor of scanner class