refactored memoization slower case out