more code restructure