build dirs correctly