Refactor

Refactor the code