use generators properly