#6175: Refactor code