Upgraded Code with few Changes