adding validation function