Writing a function