Version 3
Improved memory usage