PA2. Final commit with comments

added comments for both functions, as required by grading rules