Some code rewrote