refactor mirror generate