implementation of residual predicter