removing unnecessary thread & simplifying code