simplify and improve inliner logic