restructure, fix hanging