refactoring formula parser