Re-organising the code