rewrote most of the important stuff