Refined the code.