First code added. Essential function is here, but code needs to be made
more flexible and tested better.
Revert "First code added. Essential function is here, but code needs to be made"

This reverts commit a666202364e057f6ac2f7fee1b2549858fa69b60.
Revert "Revert "First code added. Essential function is here, but code needs to be made""

This reverts commit 3bee9ea7ed4f8f29bb6a17e00e1a8ed93f9120bf.