refactored the code, no change in functionality

added doc and removed redundant doc.