hw 1 base sol.; exception for bad input