improve logging and batch script