added json validity checks