Refactored the whole idea