fixed userRef writing function type and code generation