move function to scope