working insertionsort loop