Refactor the code to make things more readable