consolidated the LM prep/update code