added validate function