Rewrote based on Jade's example so that this actually works as a plugin