added process_line & logging functions