minor refactoring code