edited from github.com