added json encoding