finalize code restructure