refactoring: Some code duplications eliminated