structuring the code a bit