began rewrite of json controller for enhanced flexibility