1st draft completed code