cleaned up transformation code