optimised code and evading saving empty properties in data.json