Refactor based on PR feedback