Fix isValid bug