fixed merge and cleaned code