updated to support StdIn (Scanf)