Organized the code to be more object oriented and added comments