Slight rewrite of input routine