restructure of the code complete