rewrote retina adaptive code