added condition and adjust output format