Fixes code to use object instead of array