redesigned parsing and validating functions