Final touches for both functions.
Homework ready for eval by my peers