read_input and reas_source reimplmented with data structures