fixup funciton scope