optimize transform method