implementtation and refactoring of phase 3 finished