Improved scanner class