start of math and additional loops
port array functions