copy some codes to phase2