Completed third function