refactoring and polishing