some minor refactoring of code.

Added a new helper method.