applied changes from github discussion