Rewrote functions to be less nonsensical