refactor depth