update with some minor code tweaks