change the function to scope