refactor the readInputList function