implemented the basics of validate function