Build initializeComponent function, which initialises all the components