added explanation for each function as part of the programming assignment