changed back track logic