Refactored the cloneDisplay function