commented and made the code a bit prettier.