Refactor code for clarity