copyright and small refactoring