fix validity check