Refactored dirty hack