These 3 lines are repeated several times. Please extract it to a helper method.