improved json factory