improve transform logic