some minor refactoring.