fix the length check