Code for Function.