fix bugs in function inlining