Credited https://github.com/brunodecarvalho with creating the original solution.