modified thanks https://gist.github.com/4489774