using an alternative expmod
changing location
explicit multiplication instead of squaring