modified mirroring script