Added isValid function because it is needed -.-