merge of lynn's code!