restructure output