almost done, only the isValid part left.