PHASE 3 JS code