minor refactorings
minor refactoring and restructuring