Added validate function