Refactory all code