copy Marianne's updates https://gist.github.com/mkcor/4d603e94727f4bddb79a