Implementing changes from https://twitter.com/DoPhuoc/status/386591090762973184