Added code for the 2 functions. VK.
Elaborated on comments.