rewrote code