Revised the code according to the feedback of community.