extract crazy parser into a class