how to write a function