no parallel
better version of dfs