Implemented a check to make sure we don't run out of time by varying the depth