move phase2 to own function
fix dependencies