Working code
Refactoring
add comment