Added isValid checker function