refactoring and clean ups