Updated code for Phase 1