cleaned up code, export works