Added validate method and some comments