move d/l into own function