some code refactorings