Rewrote according to new specs