this is easier to read https://gist.github.com/sambev/7186526