Refactored and refined the add new case function