dind refactored a bit