Added comments and organized the code some