clean up and tested basic functionality -- global variables next