fixed max depth
clean up more efficient