added validate code