migrated addUnit function to object array as well