Revert "Refactored the code by pulling out a utility helper"

This reverts commit 6a42fcfad242816b96fca1136e1c389edb5d0b37.