Pretty much working code
merge