Refactor the code to improve the readability