back track with stack