Added Final Version of code