Add leave room function, change some structure