be more robust about input and output