Added custom stop function