pre update from sam
post sam's code merge