better not_valid function