refactored if else statement om CalculateLastRunID