added tons of comments and prettied up the code