Refactor and code style