Polished the code