make program take argument and simplify API