Printing fit coefficinets in function

I am trying to write a function that fits a gauss to data then just returns W_coef[2], or the center freq, so I have

Function Fitcenter(data)
    Wave data
    CurveFit/M=2/W=0 gauss, data/D
    Variable/G center = W_coef[2]


However, the compile debugger thing says that W_coef[2] is an unknown symbol
I'm not 100% sure but I think you need to declare the wave W_coef.

Function Fitcenter(data)
    Wave data
    CurveFit/M=2/W=0 gauss, data/D
    Wave/Z W_coef
    Variable/G center = W_coef[2]
    // alternatively to setting a global variable
    // Return W_coef[2]
End


If you return the value you can use it and avoid global variables.
Thanks for the tip in declaring that. How would I proceed in using ValDisplay with the return command?

I want to display that center frequency in a panel