Added some logic
Fixed conflicts