Fix rubbish code I wrote when I was half asleep