Homework 3 Completed with extra credits