modifying MLM script, not parsimonious and some of the functions don't work