Added checks to isValid for longer lists