fixed compilation errror, oppsss...
changed back to mod pow

TODO: The foor loop solution is unfesable, both in memory and speed