optimize run to stop searching if target has been found