fix loop in prime