implemented a cleaner way of rendering gates.