Replaced some code after merge