First attempt at structuring the code