re-structuring the code