implementtation and refactoring of phase 5 finished