refactored the code
document updated