incorporating fixes & suggestions from @robertkowalski