Function scope fix