Write the function bodies.