Add transformState function