rewrote a bit