Added validation function