Fixed doc
Refactored code