Refactor code style and remove unnecessary lines