query seg fault fixed, if bad query