changes from @iurimatias's pull request