Added the validate function