Updated function definitions

Added code to the two functions and updated comments.