Fixed a bodged if statement