refactor code and add new method for insertion sort list