refactored function call generation