Rewrote everything so it uses functions. Not actually more beautiful now