We present a model for the corrective and preventive maintenance of a system. The latter is based on a bivariate policy that replaces the system either at age
or after the
failure, whichever comes first. A repair follows each of the
first failures, restoring the system operational state, but with a lower reliability than before failing. We present two scenarios with constant and time-dependent repair costs. The results reveal that systems with low initial reliability can greatly benefit from the bivariate policy. The advantage decreases for poor quality repairs. We also obtain conditions to obtain the optimum number
when
is given. This result is helpful to assess whether a system should be replaced sooner than originally planned.