suggestions from or inspired by @pwalczysko