added a functional insertion sort