restructure init procedure