add validate function, but doesn't work