Reorginised code