refactored read_input