Update functions.py

Added missing parts of code.