moved iv calculation to be saved in user session and calculated once per user session