original version, not consider depth