implemented insertion-sort function