Rewrite the parse function to figure out the depth