updated to be suitable for corrmnebf and corrbfbf, as well as more general variable names to avoid confusion.