refactored function compilation