extract mkdir to function