move out sending directory to own function