change to array operations and add speed comparison