Fix the fetch_depth logic