making code simpler

included helper method