Fixed. Amazing what can happen when you put a = instead of a == in an if statement.