defensive version of reading input
fix?