In this paper, we consider an imperfect repair \cite{Nakagawa} where, at the $k$-th failure, the system is perfectly repaired with probability $P[N=k]$ or is minimally done with $1-P[N=k]$. The random variable $N$ represent the number of failures between consecutive perfect repairs. We investigate the properties of the distribution of time between perfect repairs and its hazard rate function. In two replacement models, it is introduced that the cost of imperfect repair is random variable and depends on age of the system. We discuss the planned replacement period which minimize the total long-run expected cost per unit time.