fix output extra space bug