changed mirror functionality; cleaned up code