optimized degree function
changed glocal to him