Write Loop Function Done