Updated to work with nested data