Revert "this code does not work"

This reverts commit a454ace2557839444009debfaff7b0707449d814.
Revert "Revert "this code does not work""

This reverts commit 8d60a3a273e92fa8364a7bc221f6adc4f34cdab8.
Revert "this code does not work"

This reverts commit a454ace2557839444009debfaff7b0707449d814.
Revert "Revert "this code does not work""

This reverts commit 8c679e6abf8e4f54e02f2e4e71afa1908f91b862.
Revert "Revert "Revert "this code does not work"""

This reverts commit aac84c6c11ec90a666755a2b611965b982ba11f4.
this code works and does not run out of memory