added code for calculating many values