Return error and fix bug in SplitFormulas