Refactored insert' to use a step-counter instead of a mutually recursive function.