fixed bug that returned invalid JSON