added some parentheses to reduce ambiguities; still out of memory error