input validation and json generation changes