polished the code