Wrote procedure function.