Made much more memory efficient