Refactored the restoreCapacity() method