Delete trailing comma
Remove else in batch method
Use global object on the client side