reverse from to calculation