changed calcDistSwitch structure and added timer for twoopt