fix invalid handling