Added validate funtion.