restructured to properly assign name, reverse logic