Refactor to make code more beautiful