Improved Code -Phase 2