coding #2 adding the function definitions