Needed more vars. In my defence, I've not written js in a while