added transform switch
corrected overflow problem