some refactoring + added beginning of insertion sort