added most of the ground work for transforming variables