move json validation up