modified to use Scanner