large update, working code