added codegen for external functions