Function parsing refactor