Created a class and moved all functions to the class. Refactored my code to work.