refactors in as_json;