updated with notes from @vieux