removed duplicate code and fixed merge conflicts
removed duplicate code and fixed merge conflicts