Move duplicate code into function