fix bug in handling mal-formed input data