made more browser-friendly
made more browser-friendly and added stringify option