Generalize ``schint'' so that it tests whether k1<k2 (outward integration) or k1>k2 (inward integration) and then acts appropriately: changes the increment in the ``for'' loop and assigns positive values to h and dk. If you are clever, you can redesign the new code so that the same ``for'' loop handles both cases. Avoiding such replication of code (where you have nearly two identical ``for'' loops) also helps to reduce bugs. Often, when you make some change, you will forget to change the replicants.