Refactored input, BUG: the last number in each string is wrong