Move duplicate code