Add initialize function (needs further tweaks)