added few comments that explain the different functions