Added validation function.