refactroring the prodcuts controller to respond to JSON