Revert "completely rewritten"

This reverts commit 82d25f2ba7650ed3fd56a8431edebbc78e324107.