Completed second homework, check the correctness