updated by contribution from @jtshinentai.