refactored code, added better export, handled alternate ui's