just added a few comments on each function