add multiple allies, localize math functions