Fixed validity function