created helper function to remove some DRY issues