Added parsing through pattern matching in encapsulated functions rather than a simple check.