replaced old json function with mroe complete one