Functions added

Added both functions. Comments follow.