added main function, improved mutate function