Re-added json reprisentation
Removed duplicate code