Added functionality for randomization,added a log file