private method for validation