Makes brain hurt, but gotta keep consistent JS style with original here.