Stupid mistake with variable reassignment