added memoize function from addy osmani and analyzed it