Designing a fast and adaptive error correction scheme for increasing the lifetime of phase change memories