First almost working code
Resolving conflicts