parse_line method from large patch