memoize this - http://www.railway.at/articles/2008/09/20/a-guide-to-memoization/