Separating the checkExpression functionality into two functions: identifyFunctions, which, given a string, identifies which functions it contains, and checkFunction (or a similar name), which checks if a function exists.