final version with lots of comments to be deleted