updated with comments, yummy code