Made functions instead of while loops in the main method. Made dictionarys instead of lists.