fixed bugs after code merge