Changed nthPow to work for all cases