improved power() function