Código em: https://gist.github.com/sistematico/c1bdf247c69edd60206b48fa9bc4cf11