modified to fix leave calculations on edit leave