refactor code for clarity