Refactor crap code