Renamed function so it is automatically called on edit