https://gist.github.com/tijmenb/956993
Fix tmp