Adding code to determine the END of as program and bypass loading any more into memory