Cleanup duplicate code