add fast powering algorithm