implement better solution for insertion sort