some more refactorings (pelase revert if it fails)