restructure codes