Took out a few more things and added in missing variable - it should hopefully work now.