Make function self sufficient (no adding to global var)
Refactor 015 to cache previous results