modified code for restructure