Refactored Code into the Helper file