rewrote the algorithm camera