Refactor and clean code