Update , add more comments, make it easier to read