memoized some functions and fixed bug where multiple values could be assigned