improved json handling