Filled in both functions with code and comments.