Implemented a different mutate function but not debugged yet. The old code is still here