Started final script which has whole phasing procedure. Editing code slightly to be more efficient