add logging and solve graceful stop problem