some js changes and serializing to JSON