Updated implementation part - still work in progress.