slight speed improvements because now using stack instead of heap