final code from event, still needs some clean up and docs