made validate method versatile