avoid using Object.keys for memory efficiency or something