final fixing
reformating some code
small refactoring