cleaned up code to facilitate code timing measurments