extracted redundant code into helpers