Final version. Good job for this homework