Changed "then" to "$then"