finished phasing script