small parsing code refactor