Code refactoring (moved method for sharing).