move mkdir outside of lambda and p loop