refactored the shit out of my JS and made comments.