Re-structuring the code