restructure and clean up