added json mode support