Rewrite list dir function and add argument parse