add parameter -p for mkdir to prevent error message if dir already exist
improve code