code organization and cleanup for demo