more memoizations to improve performance