Refactor code to improve readability