added depth first implementation of explore