simplify and restructure slightly