Added two helper methods to refactor code