Initial code comments and attempt at required logic. Cached results being returned upon subsequent execution are not yet correct.