Implement validation function