add some minor refactoring after diff