if JS profilers didn't suck so much, I could've optimised this.